package exam.business.service;

import java.util.Date;

import exam.common.constant.ResultPort;
import exam.common.key.KeyUser;
import exam.common.util.NullCheckUtil;
import exam.model.dao.TUserDAO;
import exam.model.entity.TUserEntity;
import exam.system.business.AbstractService;
import exam.system.business.BusinessServiceInfo;

public class UserUpdateService extends AbstractService {
	private TUserDAO tUserDAO = new TUserDAO();
	@Override
	public String executeService(BusinessServiceInfo serviceInfo)
			throws Exception {
		// TODO Auto-generated method stub
		TUserEntity tUserEntity = serviceInfo.getObject(KeyUser.T_USER_ENTITY);
		if(NullCheckUtil.isNotNull(tUserEntity)) {
			tUserEntity.setUpdateDate(new Date());
			// Goi phuong thuc cap nhat thong tin nguoi dung
			int update = tUserDAO.updateUser(tUserEntity);
			if(update == 0) {
				return ResultPort.FAIL;
			}
		}
		return ResultPort.SUCCESS;
	}
}
